package zmj.test.javaparser.util;

import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.List;

public class FindFileVisitor extends SimpleFileVisitor<Path> {
    private List<String> fileNameList = new ArrayList<>();

    private String fileSuffix;

    public FindFileVisitor(String fileSuffix) {
        this.fileSuffix = fileSuffix;
    }

    @Override
    public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
        if (file.toString().endsWith(fileSuffix)) {
            fileNameList.add(file.toString());
        }
        return FileVisitResult.CONTINUE;
    }

    public List<String> getFileNameList() {
        return fileNameList;
    }
}
